//
//  LGGemeteryViewController.m
//  ligenyun
//
//  Created by Mac on 2018/4/9.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGGemeteryDetailViewController.h"
#import "LGGemeteryCollectionViewCell.h"
#import "UICollectionView+STNoresult.h"
@interface LGGemeteryDetailViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property(nonatomic, strong) UICollectionView                     *collectionView;

@end

@implementation LGGemeteryDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"沅陵墓地";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    
    __weak typeof(self) weakSelf =  self;
    
    
    self.view.backgroundColor = TM_backgroundColor;
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, [TMUtils navgationBarBootom], UIScreenWidth, 130)];
    
    UIImageView * bannerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 115, 100)];
    bannerImageView.image = [UIImage imageNamed:@"纪念馆01"];
    [header addSubview:bannerImageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(bannerImageView.right  +10, bannerImageView.top, UIScreenWidth - 20 - bannerImageView.right, 20)
                                                text:@"宋庆龄陵园  北京"
                                           textColor:FirstTextColor
                                                font:18
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [header addSubview:titleLable];
    
    STLabel * desLable = [[STLabel alloc] initWithFrame:CGRectMake(bannerImageView.right  +10, titleLable.bottom, UIScreenWidth - 20 - bannerImageView.right, 40)
                                                     text:@"宋庆龄陵园现在官方明明人中华人名工俄国名誉主席宋庆龄"
                                                textColor:SecendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [header addSubview:desLable];
    

    
    STButton * lookButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 70, 30)
                                                title:@"查看地图"
                                           titleColor:[UIColor whiteColor]
                                            titleFont:14
                                         cornerRadius:4
                                      backgroundColor:TM_redColor
                                      backgroundImage:nil
                                                image:nil];
    lookButton.right = UIScreenWidth - 10;
    lookButton.bottom = header.height - 20;
    lookButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [header addSubview:lookButton];
    [lookButton setClicAction:^(UIButton *sender) {
        STWebViewController * webVC = [[STWebViewController alloc] initWithUrl:@"http://jiangqingqian.mzgtuan.com/vrpano/vrpano20/"];
        [weakSelf.navigationController pushViewController:webVC animated:YES];
    }];
    [self.view addSubview:header];
    

    UICollectionViewFlowLayout * flow = [UICollectionViewFlowLayout new];
    flow.scrollDirection = UICollectionViewScrollDirectionVertical;
    flow.minimumLineSpacing = 10;
    flow.minimumInteritemSpacing = 10;
    flow.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, header.bottom, UIScreenWidth, [TMUtils tabBarTop] - header.bottom + 49) collectionViewLayout:flow];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.backgroundColor = TM_backgroundColor;
    [self.collectionView registerClass:[LGGemeteryCollectionViewCell class] forCellWithReuseIdentifier:@"item"];
    [self.view addSubview:self.collectionView];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    if (IOS11 && [self.collectionView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
        [self.collectionView setContentInsetAdjustmentBehavior:@(2)];
    }
    self.collectionView.st_noreslutView = [[STNoresultView alloc] initWithFrame:CGRectMake(0, 100, 300, 300) title:@"" buttonTitle:@"" buttonHandle:^(NSString *titleString) {
        
    }];
    self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self sendGemeterListRequest];
    }];
    //[self.collectionView.mj_header beginRefreshing];
}
#pragma --mark UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
     CGFloat itemwith = (UIScreenWidth - 30 - 20)/2;
    return CGSizeMake(itemwith, LGGemeteryCollectionViewCell.itemHeight);
}
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    LGGemeteryCollectionViewCell * item =[collectionView dequeueReusableCellWithReuseIdentifier:@"item" forIndexPath:indexPath];
    return item;
}
#pragma --mark UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    [self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
#pragma mark --NetWork Method
- (void)sendGemeterListRequest{
    
}
@end
